<template>
    <div class="setting_conttent box">
        <div class="tt box">
            <input type="text" v-model = "wechat" placeholder="设置微信号" class="box">
            <button @click="onSaveBtn()">保存</button>
        </div>
        
    </div>
</template>
<script>
    import { Toast } from 'vant'
    import { settingWechat } from "@/api/setting";

    export default { 
        data () {
            return {
                wechat: ''
            }
        },
        methods: {
            onSaveBtn () {
                let wechat = this.wechat;
                if (!wechat) {
                    Toast.fail({message:'请输入微信号', duration: 1000});
                    return;
                }
                this.settingWechat(wechat);
                console.log(this.wechat);
            },
            settingWechat(val){
                settingWechat({wechat: val}).then(res => {
                    console.log(res);
                    Toast.success({message: "设置成功", duration: 2000});
                    this.$router.go(-1);
                })
            }

        },
        mounted() {
            this.wechat = this.$store.state.userInfo.weixin
        },
    }
</script>
<style lang="stylus" scoped>
    .setting_conttent 
        width 100% 
        height 100vh 
        overflow hidden 
        background #f5f5f5
        position relative
        .tt
            position absolute
             
            left 0
            width 100% 
            height 100vh 
            padding .3rem
            input 
                width 100%
                height .9rem
                line-height .9rem
                overflow hidden
                border-radius 8px
                border 1px solid #eee
                background #fff
                padding 0 .3rem
            button 
                width 100%
                height .9rem
                line-height .9rem
                overflow hidden
                border-radius 8px
                border: 1px solid #d64532
                background: #d64532
                margin .4rem auto
                color #fff
</style>
